package com.tedu.doctors.controller;

import com.tedu.common.response.JsonResult;
import com.tedu.doctors.pojo.dto.DoctorParam;
import com.tedu.doctors.pojo.dto.DoctorQuery;
import com.tedu.doctors.pojo.vo.DoctorVO;
import com.tedu.doctors.service.DoctorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequestMapping("/api/doctor")
@RestController
public class DoctorController {
    @Autowired
    private DoctorService doctorService;
    @GetMapping("/list")
    public JsonResult selectDoctor(DoctorQuery doctorQuery) {
        log.debug("查询用户:参数={}", doctorQuery);
        List<DoctorVO> list = doctorService.selectDoctor(doctorQuery);
        return JsonResult.ok(list);
    }
//固定id 就是更新
    @PostMapping("/save")
    public JsonResult savaDoctor(DoctorParam doctorParam) {
        log.debug("增加用户:参数={}", doctorParam);
        doctorService.savaDoctor(doctorParam);
        return JsonResult.ok();
    }
    @PostMapping("/delete/{doctorId}")
    public JsonResult deleteDoctor(@PathVariable Long doctorId) {
        log.debug("删除用户:参数={}", doctorId);
        doctorService.deleteDoctor(doctorId);
        return JsonResult.ok();
    }
//    @PostMapping("/update/{doctorId}")
//    public JsonResult updateDoctor(@PathVariable Long doctorId) {
//        log.debug("更新用户:参数={}", doctorId);
//        doctorService.updateDoctor(doctorId);
//        return JsonResult.ok();
//    }
}
